package com.dns.server.secondary;

public class Configurations {
	public
	static final int NUM_CMDL_LINE_ARGS = 6;
	static String domain;
	static String myIPddress;
	static int portForRequests;
	static String primaryServerIP;
	static int primaryServerPortForResponse;
	static String domainDataFile;
	
		static void parseCommandLineArguments(String[] args)
		{
			/*
			 * Check command line arguments whether we have received the URL.
			 */
			if( (args.length < NUM_CMDL_LINE_ARGS) || (args.length > NUM_CMDL_LINE_ARGS) ){
				System.out.println("Enter the following args :");
				System.out.println(" Domain Name \n Secondary Port No \n Primary IP Address \n Primary IP Port ");
				throw new IllegalArgumentException("invalid number of command line arguments".concat(Integer.toString(args.length)));
			}
			
			int index = 0;
			domain = args[index];
			System.out.println(" Domain: ".concat(domain));
			
			++index;
			myIPddress = args[index];
			System.out.println(" Secondary Server IP: ".concat(domain));
			
			++index;			
			portForRequests = Integer.parseInt(args[index]);
			System.out.println(" Secondary Server Port: ".concat(Integer.toString(portForRequests)));
			
			++index;
			primaryServerIP = args[index];
			System.out.println(" PrimaryServerIP: ".concat(primaryServerIP));
			
			++index;
			primaryServerPortForResponse = Integer.parseInt(args[index]);
			System.out.println(" PrimaryServerPort: ".concat(Integer.toString(primaryServerPortForResponse)));
			
			++index;
			domainDataFile = args[index];			
			System.out.println(" DomainDataFile: ".concat(domainDataFile));
		}		
}
